﻿@using Pay.DTO;
@using Pay.Core;
@{
    ViewBag.Title = "我的银行卡";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var myBankCard = ViewBag.MyBankCard as api_merchant_bank_card_dto;
}

<body class="page-bank">
    <div>
        @if (myBankCard == null) {
            <!-- 未添加银行卡 -->
            <div class="noAddCard">
                <div class="nothing fn-center">
                    <div class="img">
                        <img src="~/Content/css/tokenmall/img/bank.png" />
                    </div>
                    <p class="col-gray fn28">您尚未添加银行卡</p>
                </div>
                <div class="btnBox">
                    <a href="@Url.Action("EditBankCard","MerchantBankCard")" class="btn-addCart">+ 添加银行卡</a>
                </div>
            </div>
        } else if (myBankCard.status == EMerchantBankCardStatus.ToAudit) {
            <!-- 审核中 -->
            <div class="">
                <div class="nothing fn-center">
                    <div class="img">
                        <img src="~/Content/css/tokenmall/img/bank1.png" />
                    </div>
                    <p class="col-gray fn28">您的银行卡信息正在审核中...</p>
                </div>
            </div>
        } else if (myBankCard.status == EMerchantBankCardStatus.AutoApproved || myBankCard.status == EMerchantBankCardStatus.Approved) {
            <!-- 审核通过 -->
            <div class="myCard">
                <div class="ui-card">
                    <i class="icon-bank fn-left"></i>
                    <div class="text">
                        <div>
                            <a href="javascript:removeBankCard(@myBankCard.id)" class="btn fn-right">删除</a>
                            <a href="@Url.Action("EditBankCard","MerchantBankCard")" class="btn fn-right mr20">修改</a>
                            <span class="fn36">
                                <em class="fn36">@myBankCard.bank_name</em><br>
                                <em class="fn24">@(myBankCard.account_name.Length > 2 ? myBankCard.account_name.ReplaceWithSpecialChar(1,1) : myBankCard.account_name.ReplaceWithSpecialChar(1, 0))</em>
                            </span>
                        </div>
                        <div class="bankNo fn36">
                            <em>****</em><em>****</em><em>****</em><em>@(myBankCard.account_num.Length <= 4 ? myBankCard.account_num : myBankCard.account_num.Substring(myBankCard.account_num.Length - 4))</em>
                        </div>
                    </div>
                </div>
            </div>
        } else if (myBankCard.status == EMerchantBankCardStatus.AuditFail) {
            <!-- 审核未通过 -->
            <div class="noPass">
                <div class="box">
                    <div class="myCard">
                        <div class="ui-card">
                            <i class="icon-bank2 fn-left"></i>
                            <div class="text">
                                <div>
                                    @*<a href="javascript:removeBankCard(@myBankCard.id)" class="btn fn-right">删除</a>
                                    <a href="@Url.Action("EditBankCard","MerchantBankCard")" class="btn fn-right mr20">修改</a>*@
                                    <span class="fn36">
                                        <em class="fn36">@myBankCard.bank_name</em><br>
                                        <em class="fn24">@(myBankCard.account_name.Length > 2 ? myBankCard.account_name.ReplaceWithSpecialChar(1, 1) : myBankCard.account_name.ReplaceWithSpecialChar(1, 0))</em>
                                    </span>
                                </div>
                                <div class="bankNo fn36">
                                    <em>****</em><em>****</em><em>****</em><em>@(myBankCard.account_num.Length <= 4 ? myBankCard.account_num : myBankCard.account_num.Substring(myBankCard.account_num.Length - 4))</em>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <p class="col-red fn28 fn-center">您的银行卡信息审核未通过！</p>
                <div class="btnBox">
                    <a href="@Url.Action("EditBankCard","MerchantBankCard")" class="ui-btn-afresh">重新提交</a>
                </div>
            </div>
        }
    </div>
</body>

<script type="text/javascript">
    //删除银行卡
    function removeBankCard(id) {
        swal({
            title: "您确定要删除该银行卡吗？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false,
            data: {id:id},
            //设置closeOnConfirm: false，下面二次确认按钮被点击后才会关闭模态框
        },
            function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        url: '@Url.Action("RemoveBankCard", "MerchantBankCard")',
                        type: 'POST',
                        data: { id: id },
                        success: function (result) {
                            if (result.result_code == 1000) {
                                layer.msg("删除成功");
                                setTimeout(function () { window.location.reload(); }, 1000)
                            } else {
                                layer.msg(result.result_msg);
                            }
                        }
                    })
                } else {
                    swal({
                        title: "",
                        text: "",
                        type: ""
                    });
                }

            });
    }

</script>